--[[ 编码: WMS-16-11 名称: 盘点计划-按钮-启动 作者:HAN 日期:2025-1-29 级别:固定 (说明本段代码在项目中不太会变化) 函数: StartCount 功能: -- N_B_STATE = 0 的盘点计划启动盘点,根据计划盘点类型生成【计划盘点容器】 -- 【计划盘点容器采用】生成采用 WFP 来进行处理 更改记录: --]] json = require ("json") mobox = require ("OILua_JavelinExt") m3 = require("oi_base_mobox") function StartCount ( strLuaDEID ) local nRet, strRetInfo local data_json nRet, data_json = m3.GetSysDataJson( strLuaDEID ) if (nRet ~= 0) then lua.Error( strLuaDEID, debug.getinfo(1), data_json ) end local nCount = #data_json if ( nCount == 0 ) then return end local obj for n = 1, nCount do nRet, obj = m3.ObjAttrStrToLuaObj( "Count_Plan", lua.table2str(data_json[n].attrs) ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "m3.ObjAttrStrToLuaObj 失败! "..obj ) end if ( obj.b_state == nil ) then lua.Error( strLuaDEID, debug.getinfo(1), "盘点计划列表Grid中需要有一个N_B_STATE列属性! " ) end -- 增加一个后台触发脚本程序 if ( obj.b_state == 0 ) then local add_wfp_paramter = { wfp_type = 1, -- 触发数据对象事件(指定数据对象标识) cls = "Count_Plan", obj_id = data_json[n].id, trigger_event = "盘点计划启动" } nRet, strRetInfo = m3.AddSysWFP( strLuaDEID, add_wfp_paramter ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), strRetInfo ) end -- 更新盘点计划业务状态 local strCondition local id = lua.trim_guid_str( data_json[n].id ) strCondition = "S_ID = '"..id.."'" local strSetAttr = "N_B_STATE = 1 " nRet, strRetInfo = mobox.updateDataAttrByCondition( strLuaDEID, "Count_Plan", strCondition, strSetAttr ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "updateDataAttrByCondition失败"..strRetInfo ) end else lua.Warning( strLuaDEID, debug.getinfo(1), "盘点计划对象标识 = '"..data_json[n].id.."' 已经启动过不需要再次启动!" ) end end -- 前端刷新一下点中行 local strAction = '[{"action_type":"refresh_cur_row","value":""}]' nRet, strRetInfo = mobox.setAction(strLuaDEID, strAction) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction错误: "..strRetInfo) end end